#ifndef _TALK_SESSION_STR_STRCOMMON_H_
#define _TALK_SESSION_STR_STRCOMMON_H_

#ifndef _WIN32
#	ifndef POSIX
#		define POSIX
#	endif
#endif

#ifdef POSIX
#include <sys/socket.h>
#include <netinet/in.h>
#endif
#ifdef _WIN32
#include <WinSock2.h>
#endif


/***********************************************************************************/
/***********************************************************************************
                                   common struct
 ***********************************************************************************/
/***********************************************************************************/
struct connectopts{
	int           version;
	char		  address[64];
	int			  auth_port;
	int			  video_port;
	int			  audio_port;
	struct sockaddr_in   server_auth;       // control manager server ip:port
	struct sockaddr_in   server_control;    // control channel server ip:port
	struct sockaddr_in   server_video;      // gdi server ip:port
	struct sockaddr_in   server_audio;      // sound server ip:port
};

struct connectoptsEx{
	unsigned int	ip;
	unsigned int	version;
	unsigned short	type;	//type defined as enum ConnectType above
	unsigned short	ports[7];
};

/***********************************************************************************/
/***********************************************************************************
                                   common enum
 ***********************************************************************************/
/***********************************************************************************/
enum StrJingleType {
	STR_JINGLE_RECEIVER = 0,
	STR_JINGLE_SENDER,
};

enum StrLoginType {
	STR_LOGIN_TYPE_SIMPLE = 0,
	STR_LOGIN_TYPE_HTTPS,
	STR_LOGIN_TYPE_MAX_COUNT
};

enum StrLoginStatus {
	STR_LOGIN_STATE_NONE = 0,
	STR_LOGIN_STATE_START = 1,
	STR_LOGIN_STATE_LOGGING,
	STR_LOGIN_STATE_LOGGED,
	STR_LOGIN_STATE_CLOSED,
	STR_LOGIN_STATE_REGISTERING,
	STR_LOGIN_STATE_REGISTERED,
	STR_LOGIN_STATE_QUIT
};

enum StrLoginError {
	STR_LOGIN_ERROR_NONE = 0,         //!< No error
	STR_LOGIN_ERROR_XML,              //!< Malformed XML or encoding error
	STR_LOGIN_ERROR_STREAM,           //!< XMPP stream error - see GetStreamError()
	STR_LOGIN_ERROR_VERSION,          //!< XMPP version error
	STR_LOGIN_ERROR_UNAUTHORIZED,     //!< User is not authorized (rejected credentials)
	STR_LOGIN_ERROR_TLS,              //!< TLS could not be negotiated
	STR_LOGIN_ERROR_AUTH,             //!< Authentication could not be negotiated
	STR_LOGIN_ERROR_BIND,             //!< Resource or session binding could not be negotiated
	STR_LOGIN_ERROR_CONNECTION_CLOSED,//!< Connection closed by output handler.
	STR_LOGIN_ERROR_DOCUMENT_CLOSED,  //!< Closed by </stream:stream>

	STR_LOGIN_ERROR_SOCKET,           //!< Socket error
	STR_LOGIN_ERROR_NETWORK_TIMEOUT,  //!< Some sort of timeout (eg., we never got the roster)
	STR_LOGIN_ERROR_MISSING_USERNAME, //!< User has a Google Account but no nickname
	STR_LOGIN_ERROR_SOCKET_CONNECT,   //!< Network is not accessable
	STR_LOGIN_ERROR_SOCKET_CLOSE,     //!< Network is broken down
	STR_LOGIN_ERROR_GMAILADDRESS,		//!< Google Account is null
	STR_LOGIN_ERROR_GAMILPASSWORD,		//!< Google Account Password is null

	STR_LOGIN_ERROR_XMPP_SOCKET = 100,
	STR_LOGIN_ERROR_XMPP_THE_OTHER_SIDE_EXIT,

	STR_LOGIN_ERROR_REGISTER_UNKNOWN = 1000, //!< register error
	STR_LOGIN_ERROR_REGISTER_NAME_EXIST,     //!< Name exists on server
	STR_LOGIN_ERROR_REGISTER_EMAIL_EXIST     //!< Email exists on server
};

enum StrCallState{
	STR_CALL_STATE_INIT,
	STR_CALL_STATE_HTTP_REQUEST,
	STR_CALL_STATE_HTTP_REQUEST_FAILED,
	STR_CALL_STATE_P2P_UDP,
	STR_CALL_STATE_P2P_RELAY,
	STR_CALL_STATE_P2P_TCP,
	STR_CALL_STATE_P2P_SSLTCP,
	STR_CALL_STATE_P2P_DONE,
	STR_CALL_STATE_P2P_FAILED,
	STR_CALL_STATE_READY,
	STR_CALL_STATE_ENDING,
	STR_CALL_STATE_ENDED
};

enum StrSessionType{
	STR_SESSION_NORMAL,
	STR_SESSION_RELAY,
	STR_SESSION_UPNP_P2P,
	STR_SESSION_UPNP
};

enum StrTransType{
	STR_CALL_TRANS_RTP,
	STR_CALL_TRANS_TCP,
	STR_CALL_TRANS_PSEUDOTCP,
	STR_CALL_TRANS_UDP,

	//Only for XF1.0 compatibility:
	STR_CALL_TRANS_PTCP_CONTROL,
	STR_CALL_TRANS_PTCP_VIDEO,
	STR_CALL_TRANS_RTP_AUDIO,
	STR_CALL_TRANS_PTCP_DATA
};

enum StrTransClass{
	STR_TRANS_CLASS_RTP,
	STR_TRANS_CLASS_TCP,
	STR_TRANS_CLASS_PSEUDOTCP,
	STR_TRANS_CLASS_UDP
};

enum ConnectType{
	CON_TYPE_LOCAL,	//Local IP
	CON_TYPE_REAL,	//Local IP = Public IP, this is a REAL IP
	CON_TYPE_WAN,	//Public IP, get from TCP Stun
	CON_TYPE_STUN,	//? for libjingle later use
	CON_TYPE_RELAY,	//? for libjingle later use
	CON_TYPE_MAX	//Counter
};

#endif